﻿using System;
using System.Xml.Serialization;
using System.Collections.Generic;


[System.Serializable]
public class StationDetails
{
    public int StationID;
    public StationDetails()
    {

    }
    public StationDetails(int inStationID)
    {
        StationID = inStationID;
    }
}

public class StationRecord
{
    string mDBInsertCmdString = string.Empty;
    string mParamString = string.Empty;
    string mValuesString = string.Empty;

    public int StationID;
    public object Param1;
    public object Param2;
    public object Param3;
    public object Param4;
    public object Param5;
    public object Param6;
    public object Param7;
    public object Param8;
    public object Param9;
    public object Param10;
    public object Param11;
    public object Param12;
    public object Param13;
    public object Param14;
    public object Param15;
    public object Param16;
    public object Param17;
    public object Param18;
    public object Param19;
    public object Param20;

    public override string ToString()
    {

        string debugString = string.Empty;
        string emptySpace = " ";
        debugString += StationID + emptySpace;
        debugString += Param1 + emptySpace;
        debugString += Param2 + emptySpace;
        debugString += Param3 + emptySpace;
        debugString += Param4 + emptySpace;
        debugString += Param5 + emptySpace;
        debugString += Param6 + emptySpace;
        debugString += Param7 + emptySpace;  
        debugString += Param8 + emptySpace;
        debugString += Param9 + emptySpace;
        debugString += Param10 + emptySpace;
        debugString += Param11 + emptySpace;
        debugString += Param12 + emptySpace;
        debugString += Param13 + emptySpace;
        debugString += Param14 + emptySpace;
        debugString += Param15 + emptySpace;
        debugString += Param16 + emptySpace;
        debugString += Param17 + emptySpace;
        debugString += Param18 + emptySpace;
        debugString += Param19 + emptySpace;
        debugString += Param20 + emptySpace;
        return debugString;
    }

    object ConvertToObject(string inString)
    {
        mValuesString += inString + ", ";
        object o = inString;
        return o;
    }

    void AddtoParamString(string inString)
    {
        mParamString += inString + ", ";
    }

    public void SetData(List<string> inData)
    {
        int maxIndex = (inData.Count < 20) ? inData.Count : 20;

        for (int i = 0; i < maxIndex; i++)
        {
            switch (i)
            {
                case 1: Param1 = ConvertToObject(inData[i]); AddtoParamString("Param1"); break;
                case 2: Param2 = ConvertToObject(inData[i]); AddtoParamString("Param2"); break;
                case 3: Param3 = ConvertToObject(inData[i]); AddtoParamString("Param3"); break;
                case 4: Param4 = ConvertToObject(inData[i]); AddtoParamString("Param4"); break;
                case 5: Param5 = ConvertToObject(inData[i]); AddtoParamString("Param5"); break;
                case 6: Param6 = ConvertToObject(inData[i]); AddtoParamString("Param6"); break;
                case 7: Param7 = ConvertToObject(inData[i]); AddtoParamString("Param7"); break;
                case 8: Param8 = ConvertToObject(inData[i]); AddtoParamString("Param8"); break;
                case 9: Param9 = ConvertToObject(inData[i]); AddtoParamString("Param9"); break;
                case 10: Param10 = ConvertToObject(inData[i]); AddtoParamString("Param10"); break;
                case 11: Param11 = ConvertToObject(inData[i]); AddtoParamString("Param11"); break;
                case 12: Param12 = ConvertToObject(inData[i]); AddtoParamString("Param12"); break;
                case 13: Param13 = ConvertToObject(inData[i]); AddtoParamString("Param13"); break;
                case 14: Param14 = ConvertToObject(inData[i]); AddtoParamString("Param14"); break;
                case 15: Param15 = ConvertToObject(inData[i]); AddtoParamString("Param15"); break;
                case 16: Param16 = ConvertToObject(inData[i]); AddtoParamString("Param16"); break;
                case 17: Param17 = ConvertToObject(inData[i]); AddtoParamString("Param17"); break;
                case 18: Param18 = ConvertToObject(inData[i]); AddtoParamString("Param18"); break;
                case 19: Param19 = ConvertToObject(inData[i]); AddtoParamString("Param19"); break;
                case 20: Param20 = ConvertToObject(inData[1]); AddtoParamString("Param20"); break;
            }
        }
    }

    public string GetParamString()
    {
        string paramString = "StationID,";
        bool result = true;
        result =  mParamString.Length>2;

        if (result)
        {
            paramString += mParamString.Substring(0, mParamString.Length - 2);

            return paramString;
        }
    }

    public string GetValueString()
    {
        string valueString = StationID.ToString() + ",";
        bool result2 = true;
        result2 = mValuesString.Length>2;
        if (result2)
        {
            valueString += mValuesString.Substring(0, mValuesString.Length - 2);

            return valueString;
        }
    }

}

public class GTSData
{
    public string DataHeader;
    //public DateTime dateTime;
    public string TimeSignature;

    public List<StationRecord> StationRecordList = new List<StationRecord>();

    public override string ToString()
    {
        string debugString = string.Empty;
        string emptySpace = " ";

        debugString += DataHeader + emptySpace;

        debugString += TimeSignature + emptySpace;

        debugString += "\n   station record --";

        foreach (StationRecord sr in StationRecordList)
        {
            debugString += sr.StationID + emptySpace;

            debugString += sr.ToString();

            debugString += "\n";
        }

        return debugString;
    }

}